﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Gollie.Controls.BoundFields
{
	public class BoundFieldValidTo : BoundField
	{
		private static string defaultText = "N.v.t.";

		protected override string FormatDataValue(object dataValue, bool encode)
		{
			if (dataValue == null)
				return defaultText;

			DateTime dt = Convert.ToDateTime(dataValue);
			if (dt > DateTime.Today.AddYears(40))
				return defaultText;

			return dt.ToString("dd-MMM-yyyy");
		}
	}
}